content = "abc(de))f[h(ig)]"
list_ch = []
list_match = ['()', '[]', '{}']
for c in content:
    if '()[]{}'.count(c) > 0:
        list_ch.append(c)
stack_list = []
stack_index = 0

for index in range(len(list_ch)):
    if len(stack_list) < 1:
        stack_list.append(list_ch[index])
        stack_index += 1
    else:
        # 获取栈顶
        stack_top = stack_list[stack_index - 1]
        # 如果匹配出栈
        if list_match.count(stack_top + list_ch[index]) > 0:
            stack_list.pop()
            stack_index -= 1
        else:
            # 不匹配则入栈
            stack_list.append(list_ch[index])
            stack_index += 1

if stack_index == 0:
    print('匹配成功')
else:
    print('匹配失败')
